#ifndef BLOCKINGQUEUE_H_  
#define BLOCKINGQUEUE_H_  

#include <iostream>  
#define HAVE_STRUCT_TIMESPEC
#include <pthread.h>  

using namespace std;

typedef struct {
	char *pt;
	int size;
} DataBuf;

class BlockingQueue
{
public:
	BlockingQueue();
	BlockingQueue(int capacity);
	~BlockingQueue();

	bool push(DataBuf item);
	DataBuf poll();

private:
	int capacity;
	DataBuf* queue;
	int head, tail;
	pthread_mutex_t mutex;
	pthread_cond_t notFull, notEmpty;
};

#endif /* BLOCKINGQUEUE_H_ */  

